package cn.wolfcode.crm.query;

import cn.wolfcode.crm.util.DateUtil;
import com.alibaba.druid.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Getter
@Setter
public class RequireQueryObject extends QueryObject {
    private String keywords;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date beginDate;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date endDate;

    public String getKeywords(){
        return StringUtils.isEmpty(keywords) ? null : keywords;
    }

    public Date getEndDate(){
        if (endDate != null){
            return DateUtil.getEndDate(endDate);//获取最后一秒
        }
        return null;
    }
}
